// sharedWorker.js
self.onconnect = function (event) {
  // 当有新的页面连接到 SharedWorker 时，创建一个新的端口
  var port = event.ports[0]
  // 监听端口接收到的消息
  port.onmessage = function (message) {
    console.log('SharedWorker received message:', message.data)
    // 处理消息，然后回复
    var result = 'Hello from SharedWorker!'
    port.postMessage(result)
  }
}
